﻿package mortal.game.view.shopMall.data
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;

    public class ShopItemData extends Object
    {
        private var _tShopSell:TShopSell;
        private var _tShop:TShop;
        private var _itemInfo:ItemInfo;
        public var num:int = 1;
        public var type:int = 0;
        public var isUseGoldBuyGoldBind:Boolean = false;
        public var useNum:int = 0;
        public var npcId:int;
        public var isShowTips:Boolean = true;

        public function ShopItemData(param1:TShopSell)
        {
            this._tShopSell = param1;
            return;
        }// end function

        public function set tShopSell(param1:TShopSell) : void
        {
            this._tShopSell = param1;
            return;
        }// end function

        public function get tShopSell() : TShopSell
        {
            return this._tShopSell;
        }// end function

        public function get tShop() : TShop
        {
            if (this._tShop == null)
            {
                this._tShop = ShopConfig.instance.getTShopByCode(this._tShopSell.shopCode) as TShop;
            }
            return this._tShop;
        }// end function

        public function get itemInfo() : ItemInfo
        {
            if (this._itemInfo == null)
            {
                this._itemInfo = ItemConfig.instance.getConfig(this._tShopSell.itemCode);
            }
            return this._itemInfo;
        }// end function

        public function get unit() : int
        {
            if (this._tShopSell && this.type == 1)
            {
                if (this.tShop.unit == EPriceUnit._EPriceUnitCoin)
                {
                    return EPriceUnit._EPriceUnitCoinBind;
                }
                if (this.tShop.unit == EPriceUnit._EPriceUnitGold)
                {
                    return EPriceUnit._EPriceUnitGoldBind;
                }
                return this.tShop.unit;
            }
            else
            {
            }
            return this.tShop.unit;
        }// end function

        public function get prize() : int
        {
            var _loc_1:int = 0;
            var _loc_2:* = ClockManager.instance.nowDate.time;
            if (this.tShopSell.activeOffer != 0 && _loc_2 <= this.tShopSell.endDt.time && _loc_2 >= this.tShopSell.startDt.time)
            {
                _loc_1 = this.tShopSell.activeOffer;
            }
            else
            {
                _loc_1 = this.tShopSell.offer;
            }
            return _loc_1;
        }// end function

        public function get totalPrize() : int
        {
            var _loc_1:* = this.prize * this.num;
            return _loc_1;
        }// end function

    }
}
